﻿package mortal.game.manager
{
    import com.gengine.global.*;
    import com.greensock.*;
    import com.greensock.easing.*;
    import flash.display.*;
    import flash.geom.*;
    import mortal.component.window.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class FullScreenLayer extends WindowLayer
    {

        public function FullScreenLayer()
        {
            return;
        }// end function

        override public function addPopUp(param1:DisplayObject, param2:Boolean = false) : void
        {
            var tl:TweenLite;
            var displayObject:* = param1;
            var modal:* = param2;
            if (displayObject && (this.contains(displayObject) == false || isPoping(displayObject)))
            {
                if (displayObject.localToGlobal(new Point()).x + 100 > Global.stage.stageWidth)
                {
                    centerPopup(displayObject);
                }
                this.addChild(displayObject);
                setTop(displayObject);
                layerChange();
                if (displayObject is IView)
                {
                    displayObject.alpha = 0;
                    tl = new TweenLite(displayObject, 0.3, {alpha:1, ease:Cubic.easeOut, onComplete:function () : void
            {
                removePoping(displayObject);
                if (displayObject is Window)
                {
                    displayObject.dispatchEvent(new WindowEvent(WindowEvent.SHOW_END));
                }
                return;
            }// end function
            });
                    addPoping(displayObject, tl);
                }
                if (displayObject is View)
                {
                    (displayObject as View).stageResize();
                }
            }
            return;
        }// end function

        override public function stageResize() : void
        {
            var _loc_2:int = 0;
            var _loc_1:* = this.numChildren;
            while (_loc_2 < _loc_1)
            {
                
                if (this.getChildAt(_loc_2) is Window)
                {
                    (this.getChildAt(_loc_2) as Window).stageResize();
                }
                _loc_2++;
            }
            return;
        }// end function

    }
}
